/*
 * Copyright (c) 18/5/25 . All Rights Reserved.
 */
package com.cgmnx.admin.web.converter.entity;

import com.cgmnx.admin.dao.entity.NoteEntity;
import com.cgmnx.admin.model.enums.NodeAuditStatus;
import com.cgmnx.admin.model.enums.NodeType;
import com.cgmnx.admin.web.converter.Convert;
import com.cgmnx.admin.web.model.param.NoteSaveParam;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

/**
 * @author: z Date: 18/5/25 Time: 下午5:09
 * @version: 1.0.0
 */
@Component
public class NoteEntityConverter implements Convert<NoteSaveParam, NoteEntity> {

    @Override
    public NoteEntity convert(NoteSaveParam t) {

        NoteEntity entity = new NoteEntity ();
        entity.setId ( t.getId () );
        entity.setBrand ( t.getBrandName () );
        entity.setCurrency ( t.getMoney () );
        entity.setPrice ( t.getRate () );
        entity.setCountry ( t.getCountry () );

        entity.setCityId ( t.getCityId () );
        entity.setContent ( t.getContent () );
        entity.setType ( NodeType.codeOf ( t.getTypeCode () ) );
        entity.setStatus ( NodeAuditStatus.codeOf ( t.getStatusCode () ) );
        entity.setTitle ( t.getTitle () );
        entity.setImages ( t.getImages () );
        entity.setAuditTime ( new Date () );
        entity.setCreateTime ( new Date () );
        entity.setUpdateTime ( new Date () );
        entity.setCreateUser ( "HUAYANG" );
        entity.setUpdateUser ( "HUAYANG" );
        return entity;
    }

    @Override
    public List<NoteEntity> convert(List<NoteSaveParam> t) {
        throw new UnsupportedOperationException ();
    }
}
